/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 *
 */

import { expect, test } from '@jest/globals';

import { SdkVersion } from '../../../src/version/sdk-version.js';

test('test higher and equals', () => {
  const sdkVersion = new SdkVersion('3.2.7.2');
  const sdkVersion0 = new SdkVersion('3.2.7.2');
  const sdkVersion1 = new SdkVersion('3.1.8.5');
  const sdkVersion2 = new SdkVersion('4.1.1.5');
  const sdkVersion3 = new SdkVersion('0.9.5.2');
  const sdkVersion4 = new SdkVersion('2.1.1.6');
  const sdkVersion5 = new SdkVersion('3.2.2.5');
  const sdkVersion6 = new SdkVersion('4.0.0.1');
  expect(sdkVersion.isHigherThan(sdkVersion0)).toEqual(false);
  expect(sdkVersion.isHigherThan(sdkVersion1)).toEqual(true);
  expect(sdkVersion.isHigherThan(sdkVersion2)).toEqual(false);
  expect(sdkVersion.isHigherThan(sdkVersion3)).toEqual(true);
  expect(sdkVersion.isHigherThan(sdkVersion4)).toEqual(true);
  expect(sdkVersion.isHigherThan(sdkVersion5)).toEqual(true);
  expect(sdkVersion.isHigherThan(sdkVersion6)).toEqual(false);


  const sameSdkVersion = new SdkVersion('3.2.7.2');
  const sameSdkVersion2 = new SdkVersion('3.0.0.1');
  const sameSdkVersion3 = new SdkVersion('0.0.0.0');
  const sameSdkVersion4 = new SdkVersion('4.0.0.1');
  expect(sdkVersion.equals(sameSdkVersion)).toEqual(true);
  expect(sdkVersion.equals(sameSdkVersion2)).toEqual(false);
  expect(sdkVersion.equals(sameSdkVersion3)).toEqual(false);
  expect(sdkVersion.equals(sameSdkVersion4)).toEqual(false);
});
